﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;

namespace Sicurezza.CA.DataProvider
{
    public class AuthenticationDataProvider
    {
        public bool Authenticate(string username, string shaPassword)
        {
            bool result = false;
            using (OleDbConnection conn = new OleDbConnection(ConnectionStringDataProvider.ConnectionString))
            {
                string query = "SELECT * " +
                               "FROM Users " +
                               "WHERE User='"+username+"' AND Pass='"+shaPassword+"'";

                OleDbCommand cmd = new OleDbCommand(query, conn);
                conn.Open();
                OleDbDataReader dr = cmd.ExecuteReader();

                result = dr.HasRows;
            }

            return result;
        }

        
    }
}
